import Vue from 'vue'
import App from './App'
import uView from "@/uni_modules/uview-ui";
import * as api from './common/api';
import * as util from './common/util.js'
Vue.use(uView);

Vue.config.productionTip = false

Vue.prototype.$api = api;
Vue.prototype.$util = util;

Vue.prototype.phoneReg = /^(0|86|17951)?(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])[0-9]{8}$/;//手机号的验证
//判断是否微信访问
Vue.prototype.isWeiXinLogin = () => {
	var ua = window.navigator.userAgent.toLowerCase();
	// console.log(ua);//mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1
	if (ua.match(/MicroMessenger/i) == 'micromessenger') {
		return true; // 微信中打开
	} else {
		return false; // 普通浏览器中打开
	}
}
let u = navigator.userAgent,isAndroid = null, isiOS = null;
isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
Vue.prototype.$isAndroid = isAndroid;
Vue.prototype.$isiOS = isiOS;

Vue.prototype.checkLogin = (url) => {
	let token = uni.getStorageSync('token')
	if(token){
		uni.navigateTo({
			url:url
		})
	}else{
		uni.clearStorageSync()
		uni.navigateTo({
			url:`/pages/login/login?redirectUrl=${url}`
		})
	}
}

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()
